//
//  FWGiftViewController.swift
//  DBS
//
//  Created by 王方伟 on 2017/4/24.
//  Copyright © 2017年 wfw. All rights reserved.
//

import UIKit
private let kIdentifier = "kIdentifier"
class FWGiftViewController: UIViewController {
    fileprivate var titles : [String]!
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.randomColor()
        automaticallyAdjustsScrollViewInsets = false
        let frame = CGRect(x: 0, y: 64, width: kScreenW, height: 300)
        titles = ["全部", "高颜值", "小鲜肉"]
        let style = FWTitleStyle()
        let layout = FWPageEmojiLayout()
        layout.colCount = 4
        layout.rowCount = 2
        style.isShowBottomLine = true
        layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10)
        let gitfView = FWPageEmojiView(frame: frame, titles: titles, style: style, isInTop: false, layout: layout)
        gitfView.register(cellClass: UICollectionViewCell.self, identifier: kIdentifier)
        gitfView.delegate = self
        view.addSubview(gitfView)
    }


}

extension FWGiftViewController : PageEmojiViewDelegate {
    func numberOfSections(in pageEmojiView: FWPageEmojiView) -> Int {
        return titles.count
    }
    
    func collectionView(_ pageEmojiView: FWPageEmojiView, numberOfItemsInSection section: Int) -> Int {
        if section == 0 {
            return 9
        }else if section == 1{
            return 7
        }
        return 19
    }
    
    func collectionView(_ pageEmojiView: FWPageEmojiView, _ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kIdentifier, for: indexPath)
        cell.backgroundColor = UIColor.randomColor()
        return cell
    }
}
